package com.twu.biblioteca;


import com.twu.biblioteca.Entity.Book;
import com.twu.biblioteca.Model.BookList;

import java.util.Iterator;
import java.util.Map;

public class BookMenu extends Menu {
    private Map<String, Book> menuOptions;
    private BookList bookList;

    public BookMenu(BookList bookList) {
        this.bookList = bookList;
        setMenuOptions();
    }

    @Override
    public void setMenuOptions() {
        menuOptions = bookList.getBookList();
    }

    @Override
    public void showMenu() {
        String menu = "";
        Iterator<Map.Entry<String, Book>> entries = menuOptions.entrySet().iterator();
        while (entries.hasNext()) {
            Map.Entry<String, Book> entry = (Map.Entry) entries.next();
            Book book = entry.getValue();
            if (!book.isCheckOut()) {
                menu = menu + book.getBookId() + ". " + book.getBookName() + "\n";
            }
        }
        System.out.println(menu);
    }
}